package com.chilli.cosima.action.logmanager;

import java.io.File;
import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.chilli.cosima.action.BaseSupport;

public class RunLogDownLoadAction extends BaseSupport
{
	/**
	 * 注释内容
	 */
	private static final long serialVersionUID = 8228773659979075796L;

	private Log log = LogFactory.getLog(RunLogDownLoadAction.class);

	private String name;

	private FileInputStream inputStream;

	public void setInputStream(FileInputStream inputStream)
	{
		this.inputStream = inputStream;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public FileInputStream getInputStream()
	{
		return inputStream;
	}

	public String getDownloadFileName()
	{
		String downFileName = name;

		try
		{
			downFileName = new String(downFileName.getBytes(), "ISO8859-1");
		} catch (UnsupportedEncodingException e)
		{
			log.error(e.getMessage(), e);
		}

		return downFileName;

	}

	public String execute() throws Exception
	{
		String logRoot = System.getProperty("webapp.root") + "/log/";
		File file = new File(logRoot + getName());
		this.setInputStream(new FileInputStream(file));
		return SUCCESS;
	}

}
